package com.yans.maps
{
	import com.yans.interfaces.ICommon;
	import com.yans.maps.consts.ItemType;
	import com.yans.maps.vo.DragVo;
	import com.yans.views.Item;
	import com.yans.views.MapDataVo;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	import flash.geom.Point;
	
	import mx.core.UIComponent;
	
	import spark.components.Image;
	import spark.components.Panel;
	
	public class MapConfig extends EventDispatcher implements IEventDispatcher
	{
		public static const DRAW_PER_TICK:int = 3000;		//每帧画的格子数
		
		public static var TILE_SIZE:Number = 40;
		public static var BLOCK:int = 0;
		public static var WALKABLE:int = 1;
		public static var HALF_TRANSPARENT:int = 2;
		public static var SAFE_PLACE:int = 4;
		public static var STALL_PLACE:int = 8;
		public static var IMAGE_CUT_SIZE:int = 300;
//		public static var MONSTER:int = 2;
//		public static var NPC:int = 5;
//		public static var JUMP_POINT:int = 6;
//		public static var START_POINT:int = 11;
//		public static var CAIJI_POINT:int = 12;
		
		public static var TILE_TYPE:int = 0;	// 0:矩形  1:菱形
		public static var EDIT_MODE:int = 0;	// 0:选择  1:画  2:删除
		public static var DRAW_MODE:int = WALKABLE;	//画格类型
		
		public static var reflesh:Boolean;		//刷新地图
		public static var event:EventDispatcher = new EventDispatcher();
		public static var mousePoint:Point;
		public static var map:MapDataVo;
		public static var mapImg:Image;
		public static var mapContainer:ICommon
		public static var drawQueue:Array = [];
		public static var files:Array = [];
		
		[Bindable]
		public static var gridTip:String;
		[Bindable]
		public static var showGrid:Boolean = true;
		[Bindable]
		public static var showThing:Boolean = true;
		[Bindable]
		public static var pathInfo:String; 
		[Bindable]
		public static var mapName:String;
		[Bindable]
		public static var mapID:String;
		[Bindable]
		public static var dragVo:DragVo;
		
		public static function addFile(name:String, id:String, path:String):void {
			if(name && name.length > 0) {
				if(files.length > 9) files.length = 9;
				files.push([name, id, path]);
				pathInfo = path;
			}
			event.dispatchEvent(new Event(Event.CHANGE));
		}
		
		public static function setState(ui:UIComponent, item:Item = null):void {
			var mainAtt:Object = ui.parentDocument.mainAttPanel;
			if(!item || item.type == 0) {
				mainAtt.currentState = "State1";
			}
			if(item) {
				if(item.type == ItemType.JUMP_POINT) {
					mainAtt.currentState = "door";
				}
				else {
					mainAtt.currentState = "npc";
				} 
				MapConfig.dragVo = item.vo;
			}
		}
		
		public function MapConfig()
		{
			mousePoint = new Point();
		}
	}
}